/*
 * 组件注释
 * @Author: machinist_wq
 * @Date: 2022-09-04 16:33:20
 * @LastEditors: machinist_wq
 * @LastEditTime: 2022-09-04 16:33:31
 * @Description: form下的选中模块
 * 人生无常！大肠包小肠......
 */
"use strict";
import React from "react";
import { Space } from "antd";

import styles from "./index.less";

const Index = props => {
  const { dataSource, value, onChange } = props;

  const handleClick = key => onChange(key);

  return (
    <div className={styles.cardRadio}>
      <Space size="middle">
        {dataSource.map(item => {
          return (
            <div
              onClick={() =>
                !item.disabled && value !== item.key && handleClick(item.key)
              }
              style={{ width: item.width ?? "auto" }}
              className={`${styles.card}
            ${value === item.key ? styles.selsected : null} `}
              key={item.key}>
              {item.value}
            </div>
          );
        })}
      </Space>
    </div>
  );
};
export default Index;
